package com.pdfbox.sample.quickstart;

import java.io.File;
import java.io.IOException;
import java.util.Calendar;
import java.util.GregorianCalendar;

import org.apache.pdfbox.Loader;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDDocumentInformation;
import org.apache.pdfbox.pdmodel.PDPage;

public class _6GetDocumentProperties {

  public static void main(String[] args) throws IOException {
    String existFileName = "E:/PdfBox_Examples/设置文档属性.pdf";

    // Loading an existing document
    File file = new File(existFileName);
//    PDDocument document = PDDocument.load(file);
    PDDocument document = Loader.loadPDF(file);
    // Getting the PDDocumentInformation object
    PDDocumentInformation pdd = document.getDocumentInformation();
    // Retrieving the info of a PDF document
    System.out.println("Author of the document is :"+ pdd.getAuthor());
    System.out.println("Title of the document is :"+ pdd.getTitle());
    System.out.println("Subject of the document is :"+ pdd.getSubject());
    System.out.println("Creator of the document is :"+ pdd.getCreator());
    System.out.println("Creation date of the document is :"+ pdd.getCreationDate());
    System.out.println("Modification date of the document is :" + pdd.getModificationDate());
    System.out.println("Keywords of the document are :"+ pdd.getKeywords());
    //Closing the document
    document.close();

    System.out.println("get " + existFileName + " success");
  }
}
